package org.xtense.tests;

import java.util.HashMap;
import java.util.List;

import org.xtense.engine.XmlFileReader;
import org.xtense.model.CAttribute;
import org.xtense.model.CDocument;
import org.xtense.model.CElement;
import org.xtense.model.CText;

public class XMLReaderTest {
	public static void main(String[] args) {
		XmlFileReader reader=new XmlFileReader();
		CDocument doc=reader.read("test.xml");
		
		HashMap<Integer, CElement> cElements=doc.getElements();
		HashMap<Integer, List<CAttribute>> cAttributes=doc.getAttributes();
		HashMap<Integer, CText> cTexts=doc.getText();
		
		System.out.println("----------Elements List----------");
		for(int i=1;i<=cElements.size();i++)
			System.out.println(cElements.get(i).getElementPre()
					+"\t"+cElements.get(i).getElementTag()
					+"\t"+cElements.get(i).getParentPre());
		System.out.println();
		
		System.out.println("----------Attributes List----------");
		for(int i=1;i<=cElements.size();i++)
			if(cAttributes.containsKey(i)) {
				List<CAttribute> cAttributeList=cAttributes.get(i);
				for(int j=0;j<cAttributeList.size();j++) {
					System.out.println(cAttributeList.get(j).getElementPre()
							+"\t"+cAttributeList.get(j).getAttributeName()
							+"\t"+cAttributeList.get(j).getAttributeValue());
				}
			}
		System.out.println();
		
		System.out.println("----------Texts List----------");
		for(int i=1;i<=cElements.size();i++)
			if(cTexts.containsKey(i))
				System.out.println(cTexts.get(i).getElementPre()
						+"\t"+cTexts.get(i).getTextContent());
		System.out.println();
		
	}
}
